/*
 * GRoomsAnalyzer.java
 *
 * Created on August 25, 2007, 1:59 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package edu.psu.bd.math.grooms;

import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.util.EnumSet;
import java.util.concurrent.BlockingQueue;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import org.cgsuite.plugin.GridEditorPanel;
import org.cgsuite.util.Grid;

/**
 *
 * @author jfp149
 */
public final class GRoomsAnalyzer extends JPanel {
    
    
    
    /** Creates a new instance of GRoomsAnalyzer */
    public GRoomsAnalyzer(GoRoom gr, Grid[] grids) {
        super(new GridBagLayout());
        
        GridEditorPanel newGep = new
                GridEditorPanel(gr.getGrid());
        newGep.setPermissions(EnumSet.noneOf(
                GridEditorPanel.Permission.class));
        
        if(grids.length==2){
        MultiLineLabel whiteGridLabel = new MultiLineLabel
                (Algorithms.toString(grids[1]));
        MultiLineLabel blackGridLabel = new MultiLineLabel
                (Algorithms.toString(grids[0]));
        JPanel blackPanel = new JPanel();
        blackPanel.setBorder(BorderFactory.createTitledBorder("Black"));
        JPanel whitePanel = new JPanel();
        whitePanel.setBorder(BorderFactory.createTitledBorder("White"));
        
        blackGridLabel.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
        whiteGridLabel.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
        blackGridLabel.setAlignment(blackGridLabel.RIGHT);
        whiteGridLabel.setAlignment(whiteGridLabel.RIGHT);
        whitePanel.add(whiteGridLabel);
        blackPanel.add(blackGridLabel);
        
        
        JPanel infoPanel = new JPanel(new GridLayout(0, 1));
        infoPanel.setBorder(BorderFactory.createEtchedBorder());
        infoPanel.add(blackPanel);
        infoPanel.add(whitePanel);
        final GridBagConstraints c3 = new GridBagConstraints ();
        c3.anchor = c3.NORTH;
        c3.fill = c3.BOTH;
        add(infoPanel,c3);}
        
        if (grids.length == 1){
            newGep.setGrid(grids[0]);
        }
        GridBagConstraints c2 = new GridBagConstraints ();
        c2.anchor = c2.NORTH;
        c2.fill = c2.BOTH;
        c2.gridx = 1;
        c2.gridy = 0;
        add(newGep,c2);
        
        if(grids.length == 2){
        
        GoTree gt = new GoTree(gr,newGep);
                
        //JPanel wrapper = new JPanel();
        //wrapper.setBorder(BorderFactory.createTitledBorder("Tree"));
        
        //wrapper.add(new JScrollPane(gt));
        
        //wrapper, infoPanel, newGep
        GridBagConstraints c = new GridBagConstraints ();
        
        c.gridx = 0;
        c.gridy = 1;
        c.gridwidth = 2;
        c.fill = c.BOTH;
        add(new JScrollPane(gt),c);
        }
        
    }

    
}
